package com.lhs.Controller;

import com.lhs.Result.Result;
import com.lhs.entity.blog.blog_like;
import com.lhs.entity.blog.blog_post;
import com.lhs.service.blog_likeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/blog/blog_like")
public class blog_likeController {



    @Autowired
    private blog_likeService blogLikeService;




    /**
     * 点赞或取消点赞
     */
    @PostMapping("/{postId}/like")
    public Result likeBlog(@PathVariable Long postId, @RequestHeader Long userId) {
        return blogLikeService.likeBlog(postId, userId);
    }

    /**
     * 获取文章点赞信息
     */
    @GetMapping("/{postId}/like-info")
    public Result getBlogLikeInfo(@PathVariable Long postId, @RequestHeader(required = false) Long userId) {
        Map<String, Object> result = blogLikeService.getBlogLikeInfo(postId, userId);
        return Result.success(result);
    }

    /**
     * 获取用户点赞的文章列表
     */
//    @GetMapping("/user/liked-blogs")
//    public Result getUserLikedBlogs(@RequestHeader Long userId,
//                                    @RequestParam(defaultValue = "1") Integer page,
//                                    @RequestParam(defaultValue = "10") Integer size) {
//        PageHelper.startPage(page, size);
//        List<blog_like> blogPosts = blogLikeService.getUserLikedBlogs(userId);
//
//        return Result.success(pageInfo);
//    }



}
